package 游游的you;

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    static int[] g = new int[3];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int m = in.nextInt();
        while (m-- > 0) {
            for (int i = 0; i < 3; i++) {
                g[i] = in.nextInt();
            }
            int res = 0, t = 0;
            t = Math.min(Math.min(g[0], g[1]), g[2]);
            res = 2 * t;
            for (int i = 0; i < 3; i++) {
                g[i] -= t;
            }
            res += Math.max(g[1] - 1, 0);
            System.out.println(res);
        }
    }
}
